//
//  ComponentManager.swift
//  Component
//
//  Created by 章旭松 on 16/8/26.
//  Copyright © 2016年 章旭松. All rights reserved.
//

import Foundation
import Alamofire

public final class ComponentManager {
    public static let sharedInstance = ComponentManager()
    
    public func invokeWithUrl(url: String) {
        print(url)
        execueteNetwork()
    }
}

public func invokeWithUrl(url: String) {
    ComponentManager.sharedInstance.invokeWithUrl(url)
}

extension ComponentManager {
    private func execueteNetwork() {
        Alamofire.request(.GET, "https://httpbin.org/get", parameters: ["foo": "bar"])
            .validate()
            .responseJSON { response in
                switch response.result {
                case .Success:
                    print("Validation Successful")
                case .Failure(let error):
                    print(error)
                }
        }
    }
}